//
//  MMCircleView.m
//  MemeMaker
//
//  Created by Phan Quang Ha on 7/30/13.
//  Copyright (c) 2013 soyo. All rights reserved.
//

#import "MMCircleView.h"

@implementation MMCircleView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self setBackgroundColor:[UIColor clearColor]];
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    CGRect rect2 = CGRectMake(1, 1, rect.size.width - 2, rect.size.width-2);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    if (_isPreviewing) {
        CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    }else{
        CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
    }
    
    CGContextFillRect(context, rect);
    
    CGContextAddEllipseInRect(context, rect2);
    CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
    CGContextStrokePath(context);
}
- (void)setFrame:(CGRect)frame
{
    [super setFrame:frame];
    [self setNeedsDisplay];
}


@end
